/*
 * @Date: 2021-09-09 14:42:51
 * @Author: Acckno1
 * @LastEditTime: 2021-09-09 15:17:56
 * @Description: 
 */
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

const int N = 31;
int pre[N], in[N];
unordered_map<int, int> pos;
bool ans;

int build(int il, int ir, int pl, int pr,int& sum) {
    int root = pre[pl];
    int k = pos[abs(root)];

    if (k < il || k > ir) {
        ans = false;
        return 0;
    }
    
    int left = 0, right = 0, ls = 0, rs = 0;
    if (k > il) left = build(il, k - 1, pl + 1, pl + 1 + k - 1 - il, ls);
    if (k < ir) right = build(k + 1, ir, pl + 1 + k - 1 - il + 1, pr, rs);

    if (ls != rs) ans = false;
    sum = ls;
    if (root < 0) {
        if (left < 0 || right < 0) ans = false;
    } else sum ++ ;

    return root;
}

inline void solution() {
    int T;
    cin >> T;
    while (T -- ) {
        int n;
        cin >> n;
        for (int i = 0; i < n; i ++ ) {
            cin >> pre[i];
            in[i] = abs(pre[i]);
        }
        sort(in, in + n);

        pos.clear();
        for(int i = 0; i < n; i ++ ) pos[in[i]] = i;
        
        ans = true;
        int sum = 0;
        int root = build(0, n - 1, 0, n - 1, sum);
        if (root < 0) ans = false;
        if (ans) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}